package com.example.server

import com.example.server.db.configDb
import com.example.server.plugins.*
import com.typesafe.config.ConfigFactory
import io.ktor.server.application.*
import io.ktor.server.config.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.ktor.util.logging.*


/**
 * 安装的模块
 */
fun Application.module() {
    configDb()
    configureRouting()
    configureSerialization()
    configureSockets()
    configureHTTP()
    configureSecurity()
}

fun main() {
//    embeddedServer(Netty, port = 8080, host = "0.0.0.0",) {
//        configureRouting()
//        configureSecurity()
//        configureSerialization()
//        configureSockets()
//    }.start(wait = true)

    embeddedServer(Netty, environment = applicationEngineEnvironment {
        log = KtorSimpleLogger("ktor.application") //LoggerFactory.getLogger("ktor.application")

        config = HoconApplicationConfig(ConfigFactory.load())

        watchPaths = listOf(
            "classes",
//            File(".").canonicalPath,
        )
        module { module() }

        connector {
            port = 48018
//            host = "127.0.0.1"
        }
    }).start(true)
}